package com.qiaofang.controller;

import com.qiaofang.dto.LoginDTO;
import com.qiaofang.request.LoginRequest;
import com.qiaofang.response.LoginResponse;
import com.qiaofang.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = {"运营用户"})
@RequestMapping(value = "/user", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping(value = "/login")
    @ApiOperation(value = "登录")
    public LoginResponse login(@RequestBody LoginRequest request) {
        LoginResponse response = new LoginResponse();
        LoginDTO dto = new LoginDTO();
        dto.setUserAccount(request.getUserAccount());
        dto.setUserPwd(request.getUserPwd());
        response.setData(userService.login(dto));
        return response;
    }

}
